﻿<!DOCTYPE html>
<%@ page language="java" import="com.newcrm.config.Const" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>企客宝</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <link rel="shortcut icon" href="/favicon.ico">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/mobileV2/css/iconfont.css?ver=<%=Const.VERSION%>">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/mobileV2/css/sm.css?ver=<%=Const.VERSION%>">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/mobileV2/css/sm-extend.min.css?ver=<%=Const.VERSION%>">

    <script type='text/javascript' src='<%=request.getContextPath()%>/mobileV2/script/zepto.min.js?ver=<%=Const.VERSION%>' charset='utf-8'></script>
    <script type='text/javascript' src='<%=request.getContextPath()%>/mobileV2/script/sm.min.js?ver=<%=Const.VERSION%>' charset='utf-8'></script>
    <script type='text/javascript' src='<%=request.getContextPath()%>/mobileV2/script/sm-extend.min.js?ver=<%=Const.VERSION%>' charset='utf-8'></script>
    <script>
    $(function () {
      'use strict';
      $(document).on("pageInit", "#page-login", function(e, id, page) {
        var $content = $(page).find('.content');
        $content.on('click','#link-login',function () {
          var _userId = $("#userId").val();
          if (_userId == "") {
            $.alert('请输入用户名');
            return;
          }
          var _password = $("#password").val();
          if (_password == "") {
            $.alert('请输入登录密码');
            return;
          }
          var _captchaCode = $("#captchaCode").val();
          if (_captchaCode == "") {
            $.alert('请输入验证码');
            return;
          }
          $.ajax({
            type: 'POST',
            url: '<%=request.getContextPath()%>/m/doLogin',
            data: {userId: _userId, password: _password, captcha:_captchaCode},
            dataType: 'json',
            timeout: 60000,
            success: function(data){
              if (data.error == "1") {
                $("#captchaCodeImage").attr('src','<%=request.getContextPath()%>/code.jpg?rand=' + Math.floor(Math.random() * 100));
                $.alert(data.msg);
                return;
              }
              $.toast('登录成功');
              window.location = "<%=request.getContextPath()%>/m/index";
            },
            error: function(xhr, type){
              $.alert('登录失败，请稍后重试');
            }
          });
        });

        $("#reload-captchaCode-link").on('click', function () {
          $("#captchaCodeImage").attr('src','<%=request.getContextPath()%>/code.jpg?rand=' + Math.floor(Math.random() * 100));
        });
      });
      $.init();
    });
    </script>
  </head>
  <body>
    <div class="page-group">
      <div class="page" id="page-login">
        <header class="bar bar-nav">
          <h1 class='title'>企客宝客户管理系统</h1>
        </header>
        <div class="content">
          <div class="list-block">
            <ul>
              <li>
                <div class="item-content">
                  <div class="item-media"><i class="icon iconfont icon-user"></i></div>
                  <div class="item-inner">
                    <div class="item-input">
                      <input type="text" name="userId" id="userId" placeholder="用户名">
                    </div>
                  </div>
                </div>
              </li>
              <li>
                <div class="item-content">
                  <div class="item-media"><i class="icon iconfont icon-password"></i></div>
                  <div class="item-inner">
                    <div class="item-input">
                      <input type="password" name="password" id="password" placeholder="密码">
                    </div>
                  </div>
                </div>
              </li>
              <li>
                <div class="item-content">
                  <div class="item-media"><i class="icon iconfont icon-captcha"></i></div>
                  <div class="item-inner">
                    <div class="item-input">
                      <input type="text" name="captchaCode" id="captchaCode" placeholder="验证码">
                      <a href="#" id="reload-captchaCode-link" style="position:absolute;right:0px;top:0.25rem;">
                        <img id="captchaCodeImage" style="height:1.5rem;" src="<%=request.getContextPath()%>/code.jpg">
                      </a>
                    </div>
                  </div>
                </div>
              </li>


            </ul>
          </div>

          <div class="content-block">
            <div class="row">
              <div class="col-100"><a href="#" id="link-login" class="button button-big button-fill button-success">登录</a></div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>